//
//  PrivacyManager.m
//  Do Not Disturb
//
//  Created by Chris Karr on 10/2/07.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "PrivacyManager.h"
#import "OpenGLScreenReader.h"
#import "Buffer.h"

@implementation PrivacyManager

- (IBAction) researchMoreInfo:(id) sender
{
	NSLog (@"more info");
}

- (BOOL) isResearchEnabled
{
	return NO;
}

- (NSString *) getResearchLabel
{
	if ([self isResearchEnabled])
		return @"Enabled";
	else
		return @"Disabled";
}

- (NSString *) getResearcherName
{
	return @"Chris J. Karr";
}

- (NSString *) getResearchURLString
{
	return @"http://www.foobar.com/";
}

- (BOOL) isResearchScreen
{
	return NO;
}

- (BOOL) isResearchAudio
{
	return YES;
}

- (BOOL) isResearchVideo
{
	return NO;
}

- (IBAction) captureScreen:(id) sender
{
	NSLog (@"capture screen - add privacy check");
	
	// Create a screen reader object
    OpenGLScreenReader * mOpenGLScreenReader = [[OpenGLScreenReader alloc] init];
    NSAssert( mOpenGLScreenReader != 0, @"OpenGLScreenReader alloc failed");

    // Create a Buffer object - we'll store our screen bits there
    Buffer *dataBuffer = [[Buffer alloc] initFullScreenSizedBuffer];
    NSAssert( mOpenGLScreenReader != 0, @"Buffer alloc failed");

    // Read the screen bits and store them in our Buffer object
    [mOpenGLScreenReader readFullScreenToBuffer: [dataBuffer baseAddress] 
            bufferBytesPerRow:[dataBuffer bytesPerRow]];

    // Finished, so let's cleanup
    [mOpenGLScreenReader release];
    mOpenGLScreenReader = nil;

    // Write our image to a TIFF file on disk
    [dataBuffer createTIFFImageFileOnDesktop];
    [dataBuffer release];
}

@end
